<template>
  <el-dialog title="新增资源组" :visible.sync="visible" width="30%">
    <el-form :model="formData">
      <el-form-item label="资源组名称：" label-width=''>
        <el-input v-model="formData.name" autocomplete="off" required="true" style="width:250px"></el-input>
      </el-form-item>
      <el-form-item label="二维码名称：" label-width=''>
        <el-input v-model="formData.qrCodeName" autocomplete="off" style="width:250px"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancel()">取 消</el-button>
      <el-button type="primary" @click="add()" >确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>

  export default {
    name: "InputDialog",
    data() {
      return {
        visible: false,
        result: '',
        formData:{},
      }
    },
    props: {
      bookId: {
        type: String,
        default: '',
      },
      cateId: {
        type: String,
        default: '',
      },
    },
    methods: {
      add(){
        const loading = this.$loading({
          lock: true,
          text: '保存中...'
        });
        let param = JSON.parse(JSON.stringify(this.formData))
        param.bookId=this.bookId;
        param.cateId=this.cateId;
        console.log(param)
        this.axios.post(CONST.SERVICE_REST_PACKAGE + "increaseResource/create", param)
          .then(() => {
            this.$parent.addGetResourceTableData();
            loading.close();
        }).catch((error) => {
          loading.close();
          console.error(error)
        })
        this.closeDialogue()
      },
      cancel(){
        this.closeDialogue()
      },
      closeDialogue(){
        this.formData = {}
        this.visible = false
      }
    }
  }
</script>

<style scoped>

</style>
